classDiagram
    class Activity {
        <<聚合根>>
        -ActivityId id
        -DealerId dealerId
        -String name
        -String summary
        -String image
        -TimeRange registrationTimeRange
        -TimeRange participationTimeRange
        -int participantLimit
        -List~ActivityGift~ gifts
        -ActivityStatusType registrationStatus
        -ActivityStatusType participationStatus
        -boolean deleted

        +Activity(..., List&lt;ActivityGift> gifts, registrationStatus, participationStatus, deleted)
        +Activity(..., Map&lt;GiftId, Integer> gifts)

        +id() ActivityId
        +update(..., activityNameUniquenessCheckService) void
        +rename(name, activityNameUniquenessCheckService) void
        +delayRegistrationTo(LocalDateTime newDeadline) void
        +delayParticipationTo(LocalDateTime newDeadline) void
        +startRegistration() void
        +stopRegistration() void
        +startParticipation() void
        +stopParticipation() void
        +register(participant, registrationLimitService) ActivityRegistration
        +snapshot() ActivitySnapshot
    }

    class ActivityCreated {
        <<领域事件>>
    }

    class ActivityUpdated {
        <<领域事件>>
    }

    class ActivityRegistrationStarted {
        <<领域事件>>
    }

    class ActivityRegistrationEnded {
        <<领域事件>>
    }

    class ActivityParticipationStarted {
        <<领域事件>>
    }

    class ActivityParticipationEnded {
        <<领域事件>>
    }

    class ActivityRegistration {
        <<聚合根>>
    }

    class ActivityGift {
        <<实体>>
        -GiftId giftId
        -int count
    }

    class ActivityNameUniquenessCheckService {
        <<领域服务>>
        -activityRepository
        +isNameUsed(name) boolean
        +isNameUsed(activity, name) boolean
    }

    class ActivityRegistrationLimitService {
        <<领域服务>>
    }

    class ActivityRepository {
        <<仓库>>
    }


    class ActivityFactory {
        <<工厂>>
        -ActivityNameUniquenessCheckService activityNameUniquenessCheckService
        +createFactory(\n&nbsp;&nbsp;Dealer dealer,\n&nbsp;&nbsp;String name,\n&nbsp;&nbsp;String summary,\n&nbsp;&nbsp;String image,\n&nbsp;&nbsp;TimeRange visibleTimeRange,\n&nbsp;&nbsp;TimeRange usableTimeRange,\n&nbsp;&nbsp;int participantLimit,\n&nbsp;&nbsp;Map&lt;Gift, Integer&gt; gifts\n): Activity
    }

    Activity ..> ActivityCreated : 构造函数
    Activity ..> ActivityUpdated : update()
    Activity ..> ActivityRegistrationStarted : startRegistration()
    Activity ..> ActivityRegistrationEnded : stopRegistration()
    Activity ..> ActivityParticipationStarted : startParticipation()
    Activity ..> ActivityParticipationEnded : stopParticipation()
    Activity ..> ActivityRegistration : register()
    Activity "1" *-- "*" ActivityGift : 活动礼品
    Activity ..> ActivityNameUniquenessCheckService: 更新活动信息时检查名称是否被占用
    Activity ..> ActivityRegistrationLimitService: 活动报名数量限制

    ActivityRepository ..> Activity: 查询/持久化

    ActivityFactory ..> Activity: 创建活动聚合根
    ActivityFactory ..> ActivityNameUniquenessCheckService: 创建活动时检查名称是否被占用
